<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>自由课程作业章节</title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css"/>
		<script src="../../script/mui.min.js"></script>
		<script src="../../script/jquery.min.js"></script>
		<script src="../../script/jquery.knob.js"></script>
		<script src="../../script/ui.js"></script>
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/timecontrol.min.css" />
<!--		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">-->
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/attachmentCss.css">
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
		<style>
			body {
				background-color: #FFFFFF
			}
			html {
				background-color: #FFFFFF
			}
			.bases {
				height: 44px;
				width: 100%;
			}
			.student_study_freecourse_homeworkinfo_day {
				line-height: 1.2em;
				font-size: 18px;
				color: #323232;
			}
			.student_study_freecourse_homeworkinfo_time {
				color: #646464;
				font-size: 14px;
				float: right;
				padding-right: 10px
			}
			.text_fe {
				/*text-indent:2em;*/
				background: url(../../image/icon111.png) 0px top no-repeat, url(../../image/icon222.png) right bottom no-repeat;
				background-size: 16px;
				margin-top: 15px;
				/*margin:10px;*/
			}
			.bott_file {
				padding: 15px;
				width: 100%;
				height: 30px;
				line-height: 30px;
				background-color: #FFFFFF
			}
			.bott_text {
				padding: 15px;
				display: inline;
				/*padding-left: 15px;*/
			}
			.linlne {
				height: 100%;
			}
			button {
				border: 1px solid #fdaa52;
				background-color: #fdaa52;
				margin: 40px auto 40px auto;
				width: 80%;
				padding: 8px 0;
				margin-top: 30px;
				margin-bottom: 50px;
			}
			.content_div {
				background: #fff;
				margin-top: 66px;
			}
			.padding10 {
				padding-left: 10px;
				padding-top: 10px;
				padding-right: 10px;
			}
		</style>
	</head>
	<body>
		<div>
			<div class="base_style_color" id='BarAppearance'></div>
			<div class="base_navigation_bar base_style_color">
				<a class="base_left_item" href="#" onclick="onBackClick()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
				<span id="workname">作业</span>
				<a class="base_right_item"  ></a>
			</div>
		</div>
		<div class="weui_dialog_alert" id="closeAlert" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="checkNum2"></strong>
				</div>
				<div class="weui_dialog_ft">
					<a onclick="Cancel()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
		<div class="noSign" hidden="hidden" id="noData">
			<img src="../../image/icon_img.png" width="60%">
			<p class="font16 top_15 base_dark_grey" >
				暂无数据
			</p>
		</div>
		<div class="loadFailure" hidden="hidden" id="noNet">
			<img src="../../image/icon_img01.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button"  onclick="RefreshData()"class="mui-btn mui-btn-outlined">
				重新加载
			</button>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script src="../../script/attachmentManager.js"></script>
	<script type="text/javascript" src="../../script/databaseOperation.js"></script>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/common.js"></script>
	<script src="../../script/timeStampTool.js"></script>
	<script src="../../script/processing_images.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript">
		var uids = "";
		var pids = "";
		var chapterids = "";
		var jids = "";
		var winName = "";
		var backname = "";
		var work_name = "";
		var heis;
		var hight1 = 0;
		var html_type = ""//0为提交页。1为结果页
		apiready = function() {
			initHeaderUI();
			heis = api.winHeight;
			uids = $api.getStorage('cfnetppuid');
			jids = $api.getStorage('cfnetppjxid');
			pids = api.pageParam.pid;
			chapterids = api.pageParam.chapterid;
			//作业详情
			api.addEventListener({
				name : 'workinfo'
			}, function(ret, err) {
				showProgress();
				getthisdata();
			});
			api.addEventListener({
				name : 'upload_again'
			}, function(ret, err) {
				//coding...
				html_type=0;
				getthisdatas();
			});
			backKey();
			getthisdata();
			api.addEventListener({
				name : 'HomeWorkConfirmBackNotifi'
			}, function(ret, err) {
				if (ret) {
					api.closeWin();
					if (html_type == 0) {
						sendBuriedNotifi(1, '作业章节提交页', '071');
					} else {
						sendBuriedNotifi(1, '作业章节结果页', '072');
					}
				}
			});
			//			setupBewriteShowOrHide();
		};
		function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
				cid : api.pageParam.cid,
				pid : api.pageParam.pid,
				vid : api.pageParam.chapterid
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}

		//获取作业的基本信息
		function getthisdata() {
			var params = {
				uid : uids,
				jid : jids,
				pid : pids,
				vid : chapterids
			};
//							alert(JSON.stringify(params));
			showProgress();
			cfnetppPOST(url_getWork, params, true, function(data, status) {
//							alert(JSON.stringify(data));
				hideProgress();
				var codes = data.code;
				if (codes == "200") {
					var y = $('.base_navigation_bar').height() + hight1 + 22;
					//作业数据获取成功
					work_name = data.json.workname;
					// 作业名称
					$("#workname").text(work_name);
					$api.setStorage("zyisnull", "1");
					if ( typeof (data.json.content) == "undefined") {
						html_type = 0;
						sendBuriedNotifi(0, '作业章节提交页', '071');
						api.openFrame({
							name : 'new_student_study_freecourse_homework',
							url : 'new_student_study_freecourse_homework.html',
							pageParam : {
								datas : data,
								pid : pids,
								chapterid : chapterids,
								cid : api.pageParam.cid
							},
							rect : {
								x : 0,
								y : y,
								w : 'auto',
								h : 'auto'
							}
						});
					} else {
						html_type = 1;
						sendBuriedNotifi(0, '作业章节结果页', '071');
						api.openFrame({
							name : 'new_student_study_freecourse_homeworkinfo',
							url : 'new_student_study_freecourse_homeworkinfo.html',
							pageParam : {
								datas : data,
								pid : pids,
								chapterid : chapterids,
								cid :api.pageParam.cid
							},
							rect : {
								x : 0,
								y : y,
								w : 'auto',
								h : 'auto'
							}
						});
					}
				} else {
					$('#bewriteBtn').removeAttr('onclick');
					back('此作业已到期');
				}
			});
		}

		//退出考试提示
		function back(str) {
			$("#checkNum2").text(str);
			$('#closeAlert').show();
		}

		function Cancel() {
			$('#closeAlert').hide();
			backClick();
		}

		function getthisdatas() {
			var params = {
				uid : uids,
				jid : jids,
				pid : pids,
				vid : chapterids
			};
			showProgress();
			cfnetppPOST(url_getWork, params, true, function(data, status) {
				hideProgress();
				winName = "new_student_study_freecourse_homework";
				backname = "new_student_study_freecourse_homework";
				var y = $('.base_navigation_bar').height() + hight1 + 22;
				api.openFrame({
					name : winName,
					url : winName + '.html',
					pageParam : {
						datas : data,
						pid : pids,
						chapterid : chapterids,
						cid :api.pageParam.cid
					},
					rect : {
						x : 0,
						y : y,
						w : 'auto',
						h : 'auto'
					}
				});
				sendBuriedNotifi(0, '作业章节提交页', '071');
			});
		}

		function backKey() {
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				onBackClick();
			});
		}

		function onBackClick() {
			api.sendEvent({
				name : 'HomeWorkBackNotifi'
			});
		}

		//		function openBewrite(){
		//
		//			api.openWin({useWKWebView:true,
		//			    name: 'Student_Free_bewrite',
		//			    url: 'Student_Free_bewrite.html',
		//			    pageParam: {
		//			        cdetailtitle : api.pageParam.cdetailtitle,
		//					bewrite : api.pageParam.bewrite,
		//					is_dis_bewrite : api.pageParam.is_dis_bewrite
		//			    }
		//			});
		//		}
	</script>
</html>